package com.yanqu.road.server.cmd.activity.soulbone;

import com.yanqu.road.entity.activity.soulbone.SoulBoneConfig;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.SoulBoneProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.SoulBoneActivityMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_SOUL_BONE_NOTICE_LIST, desc = "跑马灯")
public class SoulBoneNoticeCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        SoulBoneConfig config = SoulBoneActivityMgr.getConfig();
        // 没有活动
        if (config == null || ActivityMgr.activityOverTime(config.getActivityInfo())) {
            ret = GameErrorCode.E_ACTIVITY_OVER_TIME;
            return;
        }


        player.sendPacket(Protocol.C_SOUL_BONE_NOTICE, SoulBoneProto.CrossSoulBoneNoticeReqMsg.newBuilder().setActivityId(config.getActivityInfo().getActivityId()));
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            player.sendPacket(Protocol.U_SOUL_BONE_NOTICE_LIST, SoulBoneProto.SoulBoneNoticeRespMsg.newBuilder().setRet(ret));
        }
    }
}
